<template>
<div style="width: 400px">
  <el-form ref="form" :model="form" label-width="150px">
  <el-form-item label="科室">
    <el-input v-model="form.type" maxlength="10" ></el-input>
  </el-form-item>
  <el-form-item>
    <el-button type="primary" @click="onSubmit">提交</el-button>
  </el-form-item>
  </el-form>
</div>
</template>

<script>
    export default {
        name: "Addone2",
      data() {
        return {
          form: {
            type: '',
          }
        }
      },
      methods: {
        onSubmit() {
          console.log('submit!');
          if(this.form.type==''){
            this.$message({
              message: '请填写完整的信息',
              type: 'warning'
            });
          }else {
            this.$ajax.post('http://47.75.110.31:8080/tyinfo/addOne?tyname='+this.form.type,
              {

                headers: {
                  'Content-Type': 'application/json;charset=UTF-8'
                }
              }
            ).then(response => {
              console.log(response.data);
              if (response.data == "success") {
                this.$message({
                  message: '恭喜你添加成功',
                  type: 'success'
                });
                this.form.type='';
              }
            })
          }
        }
      }
    }
</script>

<style scoped>

</style>
